//
//  RecUserInfoTableViewCell.m
//  TravelEveryDay
//
//  Created by dlios on 15-10-19.
//  Copyright (c) 2015年 com.lanou3g. All rights reserved.
//

#import "RecUserInfoTableViewCell.h"

@implementation RecUserInfoTableViewCell
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        _image = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, SCREEN_WIDTH - 20, 170)];
        _image.layer.masksToBounds = YES;
        _image.layer.cornerRadius = 5.;
        [self.contentView addSubview:_image];
        
        _nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 20, SCREEN_WIDTH - 40, 40)];
        _nameLabel.font = [UIFont boldSystemFontOfSize:20.];
        _nameLabel.textColor = [UIColor whiteColor];
        [self.contentView addSubview:_nameLabel];
        
        _timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(25, 70, SCREEN_WIDTH - 50, 30)];
        _timeLabel.font = [UIFont systemFontOfSize:14.];
        _timeLabel.textColor = [UIColor whiteColor];
        [self.contentView addSubview:_timeLabel];
        
        _lineView = [[UIView alloc] initWithFrame:CGRectMake(20, 76, 2, 20)];
        _lineView.backgroundColor = [UIColor colorWithRed:62/255 green:176/255. blue:193/255. alpha:1];
        [self.contentView addSubview:_lineView];
        
        _infoLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 130, SCREEN_WIDTH - 40, 40)];
        _infoLabel.font = [UIFont systemFontOfSize:18.];
        _infoLabel.textColor = [UIColor whiteColor];
        [self.contentView addSubview:_infoLabel];
    }
    return self;
}
-(void)getData:(RecUserNoteModel *)model
{
    [_image sd_setImageWithURL:[NSURL URLWithString:model.cover_image] placeholderImage:PLACEHOLDERIMAGE];
    _nameLabel.text = model.name;
    
    //日期转换
    NSDate *date = [NSDate dateWithTimeIntervalSince1970:model.date_added.integerValue];
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    formatter.dateFormat = @"YYYY.MM.dd";
    NSString *str = [formatter stringFromDate:date];
    
    if (![model.waypoints.stringValue isEqualToString:@"0"]) {
        _timeLabel.text = [NSString stringWithFormat:@"%@  %@天  %@足迹", str,model.day_count,model.waypoints];
    }else{
        _timeLabel.text = [NSString stringWithFormat:@"%@  %@地点故事",str,model.spot_count];
    }
    _infoLabel.text = [NSString stringWithFormat:@"%@次浏览 / %@喜欢 / %@评论",model.view_count,model.liked_count,model.total_comments_count];
}
- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
